package org.sensornet2010.test;

import java.util.Date;

import javax.microedition.lcdui.Command;
import javax.microedition.lcdui.CommandListener;
import javax.microedition.lcdui.Display;
import javax.microedition.lcdui.Displayable;
import javax.microedition.lcdui.TextBox;
import javax.microedition.midlet.MIDlet;
import javax.microedition.midlet.MIDletStateChangeException;

public class HellowWord extends MIDlet implements CommandListener {

	private Command exitCommand; // The exit command
	private Display display; // The display for this MIDlet

	public HellowWord() {
		this.exitCommand = new Command("Exit", Command.EXIT, 1);
		this.display = Display.getDisplay(this);
	}

	// Destroy must cleanup everything not handled
	// by the garbage collector.
	// In this case there is nothing to cleanup.
	protected void destroyApp(boolean unconditional) {
		// throws MIDletStateChangeException {
		// TODO Auto-generated method stub

	}

	// Pause is a no-op because there are no background
	// activities or record stores to be closed.
	protected void pauseApp() {
		// TODO Auto-generated method stub

	}

	protected void startApp() throws MIDletStateChangeException {
		TextBox t = new TextBox("HellowWorld Midlet", "Hello world", 256, 0);
		t.addCommand(this.exitCommand);
		t.setCommandListener(this);
		display.setCurrent(t);
	}

	// Respond to commands. Here we are only implementing
	// the exit command. In the exit command, cleanup and
	// notify that the MIDlet has been destroyed.
	public void commandAction(Command c, Displayable d) {
		if (c == exitCommand) {
			destroyApp(false);
			notifyDestroyed();
		}

	}
	
	public static void main(String[] args){
		System.out.println("Hello world");
		Date date = new Date();
		System.out.println("date:" + date);
		long  millis = date.getTime();
		System.out.println("ts:" + millis);
		double serial_date = 1970*365;
	    long millis_per_day = 1000*3600*24;
	    serial_date = serial_date + millis/millis_per_day;
	    System.out.println("serial:" + serial_date);
	}

}
